package com.atguigu.stgy.app.controller;

//import com.atguigu.stgy.admin.service.impl.ProvinceInfoServiceImpl;
import com.atguigu.stgy.app.service.CityInfoService;
import com.atguigu.stgy.app.service.DistrictInfoService;
import com.atguigu.stgy.app.service.ProvinceInfoService;
import com.atguigu.stgy.model.entity.CityInfo;
import com.atguigu.stgy.model.entity.DistrictInfo;
import com.atguigu.stgy.model.entity.ProvinceInfo;
import com.atguigu.stgy.model.result.R;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * (province_info)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/app/region")
///app/region/province/list
public class ProvinceInfoController {

    /**
     * 服务对象
     */
    @Resource
    private ProvinceInfoService provinceInfoService;
    @Resource
    private CityInfoService cityInfoService;
    @Resource
    private DistrictInfoService districtInfoService;
    @Operation(summary = "查询所有省")
    @GetMapping("/province/list")
    public R<List<ProvinceInfo>> list(){

        return R.ok(provinceInfoService.list());
    }
    ///app/region/city/listByProvinceId?id=36
    @Operation(summary = "查询省下所有市")
    @GetMapping("/city/listByProvinceId")
    public R<List<CityInfo>> listByProvinceId(@RequestParam("id")Long provinceId){
        return R.ok(cityInfoService.list(Wrappers.lambdaQuery(CityInfo.class)
                .eq(CityInfo::getProvinceId , provinceId)));
    }
//    /district/listByCityId?id=1101
    @Operation(summary = "查询市下所有区")
    @GetMapping("/district/listByCityId")
    public R<List<DistrictInfo>> listByCityId(@RequestParam("id")Long cityId){
        return R.ok(districtInfoService.list(Wrappers.lambdaQuery(DistrictInfo.class)
                .eq(DistrictInfo::getCityId , cityId)));
    }
    //http://localhost:8888/app/room/pageItem?provinceId=11&cityId=1101&districtId=110114&current=1&size=10
    //http://localhost:8888/app/room/pageItem?paymentTypeId=6&current=1&size=10
    //http://localhost:8888/app/room/pageItem?minRent=6000&maxRent=9000&paymentTypeId=6&current=1&size=10
    //http://localhost:8888/app/room/pageItem?minRent=6000&maxRent=9000&paymentTypeId=6&orderType=asc&current=1&size=10
    // provinceId  cityId districtId  current  size  paymentTypeId  minRent maxRent   orderType=asc 升序，desc 降序
}
